package org.real.guetshop.mapper;

import org.apache.ibatis.annotations.*;
import org.real.guetshop.pojo.dto.AddressDTO;
import org.real.guetshop.pojo.dto.EditPwDTO;
import org.real.guetshop.pojo.dto.UserUpdateDTO;
import org.real.guetshop.pojo.entity.Address;
import org.real.guetshop.pojo.entity.User;
import org.real.guetshop.pojo.vo.AddressVO;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 根据用户名获取用户数据
     * @param username
     * @return
     */
    @Select("select * from user where username = #{username}")
    User getByUsername(String username);

    /**
     * 用户注册
     * @param user
     */
    @Insert("insert into user (username, password, salt, tx,email) VALUES (#{username},#{password},#{salt},#{tx},#{email})")
    void insert(User user);

    /**
     * 根据id获取用户信息
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId}")
    User getUserById(Integer userId);

    /**
     * 更新用户信息
     * @param userUpdateDTO
     */
    void update(UserUpdateDTO userUpdateDTO);

    /**
     * 修改密码
     * @param user
     */
    @Update("update user set password = #{password},salt = #{salt} where id = #{id}")
    void editPw(User user);
}
